package com.example.redis.topic;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.concurrent.CountDownLatch;


@Slf4j
public class ReceiverRedisMessage {

    private CountDownLatch latch;

    @Autowired
    public ReceiverRedisMessage(CountDownLatch latch) {
        this.latch = latch;
    }

    /**
     * 价格趋势和市场队列消息接收方法
     *
     * @param jsonMsg
     */
    public void priceReceive(String jsonMsg) {
        log.info("[开始消费REDIS消息队列PRICE_TOPIC数据...]");
        try {
            log.info("[消费REDIS消息队列PRICE_TOPIC数据成功.]");
        } catch (Exception e) {
            log.error("[消费REDIS消息队列PRICE_TOPIC数据失败，失败信息:{}]", e.getMessage());
        }
        latch.countDown();
    }


    /**
     * 挂牌案例队列消息接收方法
     *
     * @param jsonMsg
     */
    public void listingReceive(String jsonMsg) {
        log.info("[开始消费REDIS消息队列LISTING_TOPIC数据...]");
        try {
            log.info("[消费REDIS消息队列LISTING_TOPIC数据成功.]");
        } catch (Exception e) {
            log.error("[消费REDIS消息队列LISTING_TOPIC数据失败，失败信息:{}]", e.getMessage());
        }
        latch.countDown();
    }

    /**
     * 交易案例队列消息接收方法
     *
     * @param jsonMsg
     */
    public void caseReceive(String jsonMsg) {
        log.info("[开始消费REDIS消息队列CASE_TOPIC数据...]");
        try {
            log.info("[消费REDIS消息队列CASE_TOPIC数据成功.]");
        } catch (Exception e) {
            log.error("[消费REDIS消息队列CASE_TOPIC数据失败，失败信息:{}]", e.getMessage());
        }
        latch.countDown();
    }

    /**
     * 法拍案例队列消息接收方法
     *
     * @param jsonMsg
     */
    public void foreclosureReceive(String jsonMsg) {
        log.info("[开始消费REDIS消息队列FORECLOSURE_TOPIC数据...]");
        try {
            log.info("[消费REDIS消息队列FORECLOSURE_TOPIC数据成功.]");
        } catch (Exception e) {
            log.error("[消费REDIS消息队列FORECLOSURE_TOPIC数据失败，失败信息:{}]", e.getMessage());
        }
        latch.countDown();
    }
}
